/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.dao;

import java.util.List;

import com.sigmatrix.h5.dao.impl.common.BaseDao;
import com.sigmatrix.h5.dto.StockSyncDto;
import com.sigmatrix.h5.entity.WarehouseStock;
import com.sigmatrix.h5.exception.DaoException;


/**
 *@ClassName: WarehouseStockDao
 *@Description: 库存信息数据库操作接口
 *@author youjun
 *@date 2017-06-14 09:50:39
 */
public interface WarehouseStockDao extends BaseDao<WarehouseStock>{
	
	/**
	 *@Title: findByCondition
	 *@Description: TODO()
	 *@return List<WarehouseStock>
	 *@date 2017年9月28日 下午3:34:36
	 *@param eseCode
	 *@param warehouseId
	 *@param productId
	 *@param level
	 *@throws DaoException
	 */
	List<WarehouseStock> findByCondition(final String eseCode,
			final Integer warehouseId,final Integer productId,final Integer level) throws DaoException;
	/**
	 * 
	 *@Title: findByCondition
	 *@Description: TODO()
	 *@return List<WarehouseStock>
	 *@author gaomingkai
	 *@date 2018年1月30日 下午10:10:18
	 *@param eseCode
	 *@param warehouseId
	 *@param productId
	 *@param dealearId
	 *@param level
	 *@return
	 *@throws DaoException
	 */
	List<WarehouseStock> findByCondition(final String eseCode,
			final Integer warehouseId,final Integer productId,final Integer dealearId,final Integer level) throws DaoException;
	
	/**
	 *@Title: findPartByWarehouseId
	 *@Description: 库存信息同步
	 *@return List<Stock>
	 *@date 2017年9月14日 下午9:27:27
	 *@param eseCode
	 *@param dealerId
	 *@throws DaoException
	 */
	List<StockSyncDto> findPartByWarehouseId(final String eseCode,final List<Integer> warehouseIdList) throws DaoException;

	/**
	 *@Title: findById
	 *@Description: 根据主键查找库存信息
	 *@return WarehouseStock
	 *@author youjun
	 *@date 2017-06-14 09:50:39
	 *@param id
	 *@return
	 *@throws DaoException 
	 */
	WarehouseStock findById(final Integer id, final String enterpriseCode) throws DaoException;
	
	/**
	 *@Title: save
	 *@Description: 保存库存信息
	 *@return int
	 *@author youjun
	 *@date 2017-06-14 09:50:39
	 *@param warehouseStock
	 *@throws DaoException 
	 */
	int save(final WarehouseStock warehouseStock, final String enterpriseCode) throws DaoException;
	
	/**
	 *@Title: insert
	 *@Description: 保存并返回主键Id
	 *@return Long
	 *@date 2017年9月28日 下午5:51:54
	 *@param eseCode
	 *@param warehouseStock
	 *@throws DaoException
	 */
	Long insert(final String eseCode,final WarehouseStock warehouseStock) throws DaoException;

	/**
	 *@Title: update
	 *@Description: 更新库存信息
	 *@return int
	 *@author youjun
	 *@date 2017-06-14 09:50:39
	 *@param warehouseStock
	 *@return
	 *@throws DaoException 
	 */
	int update(final WarehouseStock warehouseStock, final String enterpriseCode) throws DaoException;
	
	/**
	 *@Title: updateNumById
	 *@Description: 更新数量
	 *@return int
	 *@date 2017年9月28日 下午7:55:01
	 *@param eseCode
	 *@param id
	 *@param num
	 *@throws DaoException
	 */
	int updateNumById(final String eseCode,final Long id,final Integer num) throws DaoException;
	
	/**
	 *@Title: findListByCondition
	 *@Description: 根据条件查找库存信息列表
	 *@return List<WarehouseStock>
	 *@author youjun
	 *@date 2017-06-14 09:50:39
	 *@param warehouseStock
	 *@return
	 *@throws DaoException
	 */
	List<WarehouseStock> findListByCondition(final WarehouseStock warehouseStock, final String enterpriseCode) throws DaoException;

	/**
	 *@Title: reduceStockNum
	 *@Description: 减少指定仓库的指定产品的库存
	 *@return int
	 *@author youjun
	 *@date 2017年8月8日 上午1:39:17
	 *@param productId
	 *@param warehouseId
	 *@param singleNum <b>"变更成的"</b>单品数量
	 *@param packNum <b>"减少的"</b>包装单位数量
	 *@param enterpriseCode
	 *@return
	 *@throws DaoException
	 */
	int reduceStockNum(int productId, int warehouseId, int singleNum, int packNum, String enterpriseCode)
			throws DaoException;

	/**
	 *@Title: addStockNum
	 *@Description: 增加指定仓库的指定产品的库存
	 *@return int
	 *@author youjun
	 *@date 2017年8月8日 上午1:40:59
	 *@param productId
	 *@param warehouseId
	 *@param batchCode
	 *@param singleNum 需要增加的单品数量
	 *@param packNum 需要增加的包装数量
	 *@param enterpriseCode
	 *@return
	 *@throws DaoException
	 */
	int addStockNum(int productId, int warehouseId, String batchCode, int singleNum, int packNum, String enterpriseCode)
			throws DaoException;

	/**
	 * 
	 *@Title: findCondition
	 *@Description: TODO()
	 *@return List<WarehouseStock>
	 *@author gaomingkai
	 *@date 2017年12月19日 下午1:59:54
	 *@param eseCode
	 *@param warehouseId
	 *@param productId
	 *@param dealearId
	 *@return
	 *@throws DaoException
	 */
	List<WarehouseStock> findCondition(final String eseCode,
			final Integer warehouseId,final Integer productId,final Integer dealearId) throws DaoException;
	/**
	 * 
	 *@Title: reduceStock
	 *@Description: TODO()
	 *@return int
	 *@author gaomingkai
	 *@date 2017年12月19日 下午2:42:14
	 *@param productId
	 *@param warehouseId
	 *@param singleNum
	 *@param packNum
	 *@param dealerId
	 *@param enterpriseCode
	 *@return
	 *@throws DaoException
	 */
	int reduceStock(int productId, int warehouseId, int packlevel, int number, int dealerId, String enterpriseCode)
			throws DaoException;
}
